import type { MaterialType } from "@/pages/base/type/entity";
import apiClient from "../../apiClient";

export interface PageListReq {
  typeCode?:string;
  typeName?:string;
  page: number;
  pageSize: number;
}

export interface PageListRes {
  total: number;
  records: MaterialType[];
}

const treeList = (data: PageListReq) => apiClient.post<MaterialType[]>({ url: "/base/type/treeList", data });
const getInfo = (id: React.Key) => apiClient.get<MaterialType>({ url: `/base/type/${id}` });
const add = (data: MaterialType) => apiClient.post<MaterialType>({ url: "/base/type", data });
const update = (data: MaterialType) => apiClient.put<MaterialType>({ url: "/base/type", data });
const remove = (ids: React.Key[]) => apiClient.delete({ url: "/base/type", params: { ids: ids.join(",") } });

export default {
  treeList,
  getInfo,
  add,
  update,
  remove
};
